<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <input type="text" id="text1" />
  <input id="bnt1" type="button" value="创建li" />
  <ul id="ul1"></ul>

  <script>
    let btn1 = document.getElementById("bnt1")
    let ul1 = document.getElementById("ul1")
    let text1 = document.getElementById("text1")
    btn1.onclick = function () {
      let li = document.createElement("li")
      let fastLi = ul1.getElementsByTagName("li")
      li.innerText = text1.value
      //父级.insertBefore(子节点,原有节点)
      ul1.insertBefore(li,fastLi[0])
    }

  </script>

</body>

</html>